import QtQuick 2.6
import Qt.labs.controls 1.0
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.4
import "../lib"

Navigator {
    id: nav
    title: "我的收藏"
    submitted: false

    contentHeight: Math.max(iHEIGHT * 13, height)
    Menu {
        id: menu
         title: "Edit"

         MenuItem {
             text: "删除"


         }

     }

    ListView {
        id: view
        anchors.fill: parent
        model:ListModel {
            ListElement {
                source: "../image/__down-open__.svg"
                name: "DVD-RW 童装 50见"
                stock: 50
                price: 63.0
            }
            ListElement {
                source: "../image/__down-open__.svg"
                name: "DVD-RW 童装 50见"
                stock: 50
                price: 63.0
            }
        }



        delegate: Rectangle{
            width: view.width
            height: iHEIGHT * 2.5
            color: ms.pressed ? Theme.pressColor : "white"

            RowLayout {
                anchors.fill: parent
                anchors.margins: iWIDTH * 0.5
                spacing: iWIDTH

                Image {
                    source: model.source
                    sourceSize: Qt.size(parent.height * 0.7, parent.height * 0.7)
                    Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
                }

                ColumnLayout {
                    Layout.fillWidth: true
                    Layout.fillHeight: true
                    spacing: iHEIGHT
                    Label {
                        text: model.name
                        Layout.fillWidth: true
                    }

                    RowLayout {
                        Layout.fillWidth: true
                        Label {
                            text: "￥" + model.price.toFixed(1)
                            color: "darkred"
                            font.bold: true
                            font.letterSpacing: 1.5
                        }
                        Item {
                            Layout.fillWidth: true
                        }

                        Label {
                            text: "还剩下 " + model.stock + " 件"
                        }
                    }
                }
            }

            Rectangle {
                anchors.bottom: parent.bottom
                color: "gainsboro"
                width: parent.width
                height: 1
                visible: index != view.count - 1
            }

            MouseArea {
                id: ms
                anchors.fill: parent
                onPressAndHold: menu.popup()
            }
        }
    }
}
